package com.shiguiwu.springboot3.filter;

import lombok.Data;
import net.sf.jsqlparser.statement.Statement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @description: 处理sql
 * @author: stone
 * @date: Created by 2023/7/21 21:36
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springboot3.filter
 */
@Data
@Component
public class HandleSqlFilter {
    @Autowired
    List<AbstractSqlFilter> list;

    public Set<String> handle(Statement statement) {
        Set<String> set = new HashSet<>();
        list.stream().peek(x -> x.setStatement(statement))
                .filter(AbstractSqlFilter::isSupport)
                .forEach(x -> x.handleSql(set));
        return set;
    }
}
